import store from '@/store'
import router, {resetRouter} from "@/router";
let lastTime=new Date().getTime();

let currentTime=new Date().getTime();

let timeout=30*60*1000;

window.onload=function(){
    window.document.onmousedown=function(){
        localStorage.setItem("lastTime",JSON.stringify(new Date().getTime()));
    }
}

function checkTimeout(){
    currentTime=new Date().getTime();
    lastTime=JSON.parse(localStorage.getItem("lastTime"));
    if(currentTime-lastTime>timeout) {
               store.commit('logout')
    }
}

export default function(){
    window.setInterval(checkTimeout,3000)
}

